﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "IPropertyPanelEventArgs.h"
#include "IGnufPropertyWidget.h"
#include "IGnufPropertyPanelEvent.h"
#include "IPropertyPanelEventHandler.h"
#include "Event.h"

namespace gcmp
{
    class IEvent;
}

namespace gfam
{
    class IGnufPropertyWidget;
    class PropertyPanelEventArgs : public gcmp::IPropertyPanelEventArgs
    {
    public:
        PropertyPanelEventArgs(const std::wstring& type, const std::wstring& newValue);

        virtual const gcmp::IEvent* GetEvent() const override;
        virtual const std::wstring& GetType() const override;
        virtual const std::wstring& GetNewValue() const override;
        /// \brief 得到Property属性项Id(修改属性项时有效)
        virtual void SetPropertyItemUniqueId(const std::wstring& uniqueID) override;

        /// \brief 设置Property属性项Id(修改属性项时有效)
        virtual std::wstring GetPropertyItemUniqueId() const;

        void SetEvent(const gcmp::IEvent* pEvent);
    private:
        gcmp::WeakPtr<const gcmp::IEvent> m_wpEvent;
        std::wstring m_type;
        std::wstring m_newValue;
        std::wstring m_uniqueID; //Item uId
    };

    class GnufPropertyPanelEvent : public gcmp::Event<IGnufPropertyWidget, IGnufPropertyPanelEvent, gcmp::IPropertyPanelEventHandler, PropertyPanelEventArgs>
    {
    public:
        GnufPropertyPanelEvent(const std::wstring& name, IGnufPropertyWidget* pSender);
    };
}
